//
//  LoginViewController.m
//  XiangJi
//
//  Created by apple on 2017/8/23.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "LoginViewController.h"
#import "LookPhotoViewController.h"
@interface LoginViewController ()


@property (nonatomic, strong) NSMutableArray *loginMutArr;

@property (nonatomic, strong) NSMutableArray *loginAssetsMutArr;

@end

@implementation LoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.loginMutArr = [NSMutableArray arrayWithCapacity:0];
    self.loginAssetsMutArr = [NSMutableArray arrayWithCapacity:0];
    
    
    self.btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 300, Screen_Width, 50)];
    
    [self.btn setTitle:@"再点击这个，跳转到下个页面，去呈现图片" forState:UIControlStateNormal];
    
    [self.btn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    
    [self.btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:self.btn];
    
    
    
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.btnPhoto = [[UIButton alloc] initWithFrame:CGRectMake(0, 100, Screen_Width, 50)];
    
    [self.btnPhoto setTitle:@"先点击这个，从相册里选几张图片" forState:UIControlStateNormal];
    
    [self.btnPhoto setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    
    [self.btnPhoto addTarget:self action:@selector(btnPhotoClick:) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:self.btnPhoto];
    
}


#pragma 从相册中取下资源
- (void)createPhoto{

    self.sheet = [[ZLPhotoActionSheet alloc] init];
    
    self.sheet.sender = self;
    
    __weak typeof(self) weakSelf = self;
    
    [self.sheet showPhotoLibrary];
    
//    [self.sheet showCamera];
    
    [self.sheet setSelectImageBlock:^(NSArray<UIImage *> * images, NSArray<PHAsset *> * assets, BOOL isOriginal) {
       
        
        [weakSelf.loginMutArr addObjectsFromArray:images];
        
        NSLog(@"assets = %@",assets);
        
        [weakSelf.loginAssetsMutArr addObjectsFromArray:assets];
        
    }];
    
    
}


- (void)btnPhotoClick:(UIButton *)sender{
    
    
    [self createPhoto];
}


- (void)btnClick:(UIButton *)sender{

    LookPhotoViewController *lookvc = [[LookPhotoViewController alloc] init];
    
    lookvc.lookMutArr = _loginMutArr;
    lookvc.lookAssetsMutArr = _loginAssetsMutArr;
    
    [self.navigationController pushViewController:lookvc animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
